<div class="ui-g-12 p-20">
  <p-panel headerClass="bg-none" [showScroll]="true" marginHeight='80'>
    <p-header>
      <div class="text-right p-6-0">
        <span class="border-l-1a8fe8 p-l-8 pull-left m-t-8 }">{{title}}</span>
        <button pButton type="button" (click)="save()" class="btn {{nodeId?'btn-secondary':'btn-success'}}" label="保存"></button>
        <button pButton type="button" (click)="back()" label="取消" class="btn btn-secondary"></button>
      </div>
    </p-header>
    <form #form="ngForm" novalidate class="form-horizontal">
      <div class="ui-lg-12 ui-md-12 ui-g-nopad  head-title">
        节点信息
      </div>
      <div class="table-row">
        <div class="table-cell text-right p-l-25 p-required">
          编号：
        </div>
        <div class="table-cell min-width">
          <input type="text" pInputText class="p-input" name="code" maxlength="20" required [(ngModel)]="nodeManage.code" placeholder="请输入编号"
            (blur)="nodeCodeCk();" (focus)="nodeCodeError =''" [disabled]="nodeId" [ngClass]="nodeCodeError?'p-input-error':''">
        </div>
        <div class="table-cell">
          <p-message *ngIf="nodeCodeError" severity="error" [text]="nodeCodeError"></p-message>
        </div>
      </div>
      <div class="table-row">
        <div class="table-cell text-right p-l-25 p-required">
          名称：
        </div>
        <div class="table-cell min-width">
          <input pInputText class="p-input" name="name" maxlength="25" required [(ngModel)]="nodeManage.name" placeholder="请输入名称" (blur)="nodeNameCk();"
            (focus)="nodeNameError =''" [ngClass]="nodeNameError?'p-input-error':''">
        </div>
        <div class="table-cell">
          <p-message *ngIf="nodeNameError" severity="error" [text]="nodeNameError"></p-message>
        </div>
      </div>
      <div class="table-row">
        <div class="table-cell text-right p-l-25 p-required">
          简称：
        </div>
        <div class="table-cell min-width">
          <input pInputText class="p-input" name="shortName" maxlength="6" required [(ngModel)]="nodeManage.shortName" placeholder="请输入简称"
            (blur)="shortNameCk();" (focus)="shortNameError =''" [ngClass]="shortNameError?'p-input-error':''">
        </div>
        <div class="table-cell">
          <p-message *ngIf="shortNameError" severity="error" [text]="shortNameError"></p-message>
        </div>
      </div>
      <div class="table-row">
        <div class="table-cell text-right p-l-25">
          排序：
        </div>
        <div class="table-cell min-width">
          <p-spinner name="sort" size="30" maxlength="6" styleClass="p-spinner" [(ngModel)]="nodeManage.sortNum" placeholder="请输入排序"
            [step]="1" [min]="1" [max]="99999" (onFocus)="checkSortNumError =''"></p-spinner>
        </div>
        <div class="table-cell">
          <p-message *ngIf="checkSortNumError" severity="error" [text]="checkSortNumError"></p-message>
        </div>
      </div>
      <div class="table-row">
        <div class="table-cell text-right p-l-25 p-required">
          是否预警：
        </div>
        <div class="table-cell min-width">
          <p-dropdown required name="isWarning" [options]="isWarningStatus" placeholder="请选择是否需要预警" [style]="{width: '100%'}" [(ngModel)]="selectedWarningStatus"
            optionLabel="name" dataKey="code" (onChange)="isWarningStatusCk()"></p-dropdown>
        </div>
        <div class="table-cell">
          <p-message *ngIf="isWarningError" severity="error" [text]="isWarningError"></p-message>
        </div>
      </div>
      <div class="table-row">
        <div class="table-cell text-right p-l-25">
          预警天数：
        </div>
        <div class="table-cell icon-text min-width" data-text="天">
          <p-spinner name="warningDays" size="30" maxlength="6" styleClass="p-spinner" [(ngModel)]="nodeManage.warningDays" placeholder="请输入预警天数"
            (onFocus)="warningDaysError =''" (onBlur)="warningDaysCk();" [step]="1" [min]="0" [max]="99999" [disabled]="selectedWarningStatus?.code === false"></p-spinner>
        </div>
        <div class="table-cell">
          <p-message *ngIf="warningDaysError" severity="error" [text]="warningDaysError"></p-message>
        </div>
      </div>
      <div class="table-row">
        <div class="table-cell text-right p-l-25 p-required">
          是否监理确认：
        </div>
        <div class="table-cell min-width">
          <p-dropdown required name="isSupervisorConfirm" [options]="isSupervisorConfirm" placeholder="请选择是否监理确认" [style]="{width: '100%'}"
            [(ngModel)]="selectedConfirm" optionLabel="name" dataKey="code" (onChange)="isSupervisorConfirmCk()"></p-dropdown>
        </div>
        <div class="table-cell">
          <p-message *ngIf="isSupervisorConfirmError" severity="error" [text]="isSupervisorConfirmError"></p-message>
        </div>
      </div>
      <div class="table-row">
        <div class="table-cell text-right p-l-25">
          自动确认天数：
        </div>
        <div class="table-cell icon-text min-width" data-text="天">
          <p-spinner name="confirmDays" size="30" maxlength="6" styleClass="p-spinner" [(ngModel)]="nodeManage.confirmDays" placeholder="请输入自动确认天数"
            (onFocus)="confirmDaysError =''" (onBlur)="confirmDaysCk();" [step]="1" [min]="0" [max]="99999" [disabled]="selectedConfirm?.code === false"></p-spinner>
        </div>
        <div class="table-cell">
          <p-message *ngIf="confirmDaysError" severity="error" [text]="confirmDaysError"></p-message>
        </div>
      </div>
      <div class="table-row" *ngIf="nodeId">
        <div class="table-cell text-right p-l-25 p-required">
          状态：
        </div>
        <div class="table-cell min-width">
          <p-dropdown required name="isEffect" [options]="isEffects" placeholder="请选择状态" [style]="{width: '100%'}" [(ngModel)]="selectedisEffect"
            optionLabel="name" dataKey="code" (onChange)="isEffectCk()"></p-dropdown>
        </div>
        <div class="table-cell">
          <p-message *ngIf="isEffectError" severity="error" [text]="isEffectError"></p-message>
        </div>
      </div>
      <div class="b-b-ebebeb"></div>
      <div class="table-row">
        <div class="table-cell text-right p-l-25 p-required">
          工艺：
        </div>
        <div class="table-cell">
          <button pButton type="button" (click)="openDialogForTec()" label="选择" class="btn btn-success"></button>
        </div>
        <div class="table-cell">
          <p-message *ngIf="technologyError" severity="error" [text]="technologyError"></p-message>
        </div>
      </div>
      <div class="dataTable">
        <p-dataTable [value]="technologyList" #td [lazy]="true" [paginator]="false" [editable]="true">
          <p-column *ngFor="let col of colsConStandard" [field]='col.field' [header]='col.header' [editable]="col.editable" [style]="{'width':col.width}">
            <ng-template let-index="rowIndex" let-data="rowData" pTemplate="body" *ngIf="col.tem">
              <div *ngIf="col.field === 'technologyDetails'">
                <div *ngFor="let technology of data.technologyDetails; let i = index" class="flex-td">
                  <span>{{i+1}}.{{technology.content}}</span>
                </div>
              </div>
              <div *ngIf="col.field === 'sortNum'">
                {{index + 1}}
              </div>
              <div *ngIf="col.field === 'operation'">
                <span class="move" (click)="removeTechnology(index)">删除</span>
                <span (click)="technologyMoveUp(index);td.initColumns()" class="move">上移</span>
                <span (click)="technologyMoveDown(index)" class="move">下移</span>
              </div>
            </ng-template>
          </p-column>
        </p-dataTable>
      </div>
      <div class="b-b-ebebeb">
      </div>
      <div class="table-row">
        <div class="table-cell text-right p-l-25 p-required">
          验收标准：
        </div>
        <div class="table-cell">
          <button pButton type="button" label="添加" (click)="addStandard()" class="btn btn-primary"></button>
          <p-message *ngIf="standardError" severity="error" [text]="standardError"></p-message>
        </div>
      </div>
      <div class="dataTable">
        <p-dataTable [scrollable]="true" [value]="standardList" [lazy]="true" [paginator]="false" [editable]="true" [customWidth]="true" >
          <p-column *ngFor="let col of colsCheckStandard" [field]='col.field' [header]='col.header' [editable]="col.editable" [style]="{'width':col.width}">

            <ng-template pTemplate="header" *ngIf="col.required">
              <div *ngIf="col.field === 'checkStandard'" class="p-required required">
                {{col.header}}
              </div>
              <div *ngIf="col.field === 'phoneRequire' " class="p-required required">
                {{col.header}}
              </div>
            </ng-template>

            <ng-template let-index="rowIndex" let-data="rowData" pTemplate="body" *ngIf="col.tem">
              <div *ngIf="col.field === 'operation'">
                <span class="move" (click)="removeStandrad(index)">删除</span>
                <span class="move" (click)="standardMoveUp(index)">上移</span>
                <span class="move" (click)="standardMoveDown(index)">下移</span>
              </div>
              <div *ngIf="col.field === 'phoneRequire'">
                <div [class.p-input-error]="checkPhotos(data.phoneRequire)" class="flex-td" [pTooltip]="checkPgotosIsNull(data.phoneRequire) "
                  errorTip="true" tooltipPosition="top">
                  ≥{{data.phoneRequire}}
                </div>
              </div>
              <div *ngIf="col.field === 'isReferenceCheckItem'">
                {{data.isReferenceCheckItem.name}}
              </div>
              <div *ngIf="col.field === 'isRequestPassItem'">
                {{data.isRequestPassItem.name}}
              </div>
              <div *ngIf="col.field === 'sortNum'">
                {{index + 1}}
              </div>
              <div *ngIf="col.field === 'checkStandard'">
                <div [class.p-input-error]="checkStandard(data.checkStandard)" class="flex-td" [pTooltip]="checkStandardIsNull(data.checkStandard) "
                  errorTip="true" tooltipPosition="top">
                  {{data.checkStandard}}
                </div>
              </div>
              <div class="flex-td" *ngIf="col.field === 'checkItem' || col.field === 'tackPhoneRequire' || col.field === 'toolConfig'">
                <div>{{data[col.field]}}</div>
              </div>
            </ng-template>

            <ng-template let-index="rowIndex" let-data="rowData" pTemplate="editor" *ngIf="col.tem">
              <div *ngIf="col.field === 'phoneRequire'">
                <p-spinner [name]="'phoneRequire'+index" size="30" maxlength="6" required styleClass="p-spinner" [(ngModel)]="data.phoneRequire"
                  [step]="1" [min]="0" [max]="99999" placeholder="请输入照片"></p-spinner>
              </div>
              <div *ngIf="col.field === 'isReferenceCheckItem'">
                <p-dropdown [name]="'isReferenceCheckItem'+index" [(ngModel)]="data[col.field]" optionLabel="name" dataKey="code" [options]="isReferenceCheckItemArr"
                  [style]="{'width':'100%'}" appendTo="body" required></p-dropdown>
              </div>
              <div *ngIf="col.field === 'isRequestPassItem'">
                <p-dropdown [name]="'isRequestPassItem'+index" [(ngModel)]="data[col.field]" optionLabel="name" dataKey="code" [options]="isRequestPassItemArr"
                  [style]="{'width':'100%'}" appendTo="body" required></p-dropdown>
              </div>
              <div *ngIf="col.field === 'checkStandard' ">
                <input type="text" pInputText maxlength="50" [name]="col.field+index" class="p-input" required [(ngModel)]="data[col.field]"
                  placeholder="请输入验收标准">
              </div>
              <div *ngIf=" col.field === 'checkItem' ">
                <input type="text" pInputText maxlength="100" [name]="col.field+index" class="p-input" required [(ngModel)]="data[col.field]"
                  placeholder="请输入检查项目">
              </div>
              <div *ngIf="col.field === 'tackPhoneRequire' ">
                <input type="text" pInputText maxlength="100" [name]="col.field+index" class="p-input" required [(ngModel)]="data[col.field]"
                  placeholder="请输入拍照要求">
              </div>
              <div *ngIf="col.field === 'toolConfig'">
                <input type="text" pInputText maxlength="30" [name]="col.field+index" class="p-input" required [(ngModel)]="data[col.field]"
                  placeholder="请输入基本配备工具">
              </div>
            </ng-template>
          </p-column>
        </p-dataTable>
      </div>
      <div class="b-b-ebebeb">
      </div>
      <div class="table-row">
        <div class="table-cell text-right p-l-25 p-required">
          关联定额：
        </div>
        <div class="table-cell">
          <button pButton type="button" (click)="openDialogForQuota()" label="选择" class="btn btn-success"></button>
          <p-message *ngIf="openDialogForQuotaError" severity="error" [text]="openDialogForQuotaError"></p-message>
        </div>

      </div>
      <div class="dataTable">
        <p-dataTable [value]="quotaList" #td [lazy]="true" [paginator]="false" [editable]="true" [customWidth]="true">
          <p-column *ngFor="let col of quotaCol" [field]='col.field' [header]='col.header' [editable]="col.editable" [style]="{'width':col.width}">
            <ng-template let-index="rowIndex" let-data="rowData" pTemplate="body" *ngIf="col.tem">
              <div *ngIf="col.field === 'operation'">
                <span class="move" (click)="removeQuota(index)">删除</span>
              </div>
            </ng-template>
            <ng-template let-index="rowIndex" let-data="rowData" pTemplate="body" *ngIf="col.dic">
              <span> {{storage.dicFilter(col.dic,data[col.field])}} </span>
            </ng-template>
          </p-column>
        </p-dataTable>
      </div>

    </form>
  </p-panel>
</div>

<p-dialog header="选择工艺" [(visible)]="W001" modal="modal" width="800" [responsive]="true" (onHide)="selectedRowData=[]">
  <div class="p-8-0">
    <div class="m-r-15 inline-block">
      <span class="p-r-10">类型： </span>
      <p-dropdown placeholder="请选择工艺类型" styleClass="width-200 m-r-30" [options]="technologyStatus" [(ngModel)]="selectedType" [ngModelOptions]="{standalone: true}"
        optionLabel="name" (onChange)='search()' dataKey="code" required></p-dropdown>
    </div>
    <div class="width-250 relative pull-right">
      <input type="text" class="width-full p-input p-r-28" pInputText maxlength="20" [(ngModel)]="searchObj.searchValue" placeholder="名称/编号"
        (keyUp.enter)="search()">
      <span class="icon-search-right" (click)="search()"></span>
    </div>
  </div>

  <p-dataTable scrollable="true" scrollHeight="260px" [style]="{marginTop:'12px'}" [value]="listData" [totalRecords]="totalRecords"
    [loading]="loading" [lazy]="true" (onPage)="onPage($event)" [paginator]="true" [(selection)]="selectedRowData" [headerCheckboxToggleAllPages]="true">
    <p-column [style]="{'width':'38px'}" selectionMode="multiple"></p-column>
    <p-column *ngFor="let col of teccols" [field]='col.field' [header]='col.header' [hidden]="col.hidden">
      <ng-template let-index="rowIndex" let-data="rowData" pTemplate="body" *ngIf="col.tem">

      </ng-template>
    </p-column>
  </p-dataTable>
  <div class="text-center">
    <button pButton type="button" [label]="'保存'" (click)="saveStandrad()" class="btn btn-success m-btn-dialog"></button>
  </div>
</p-dialog>

<p-dialog header="选择定额" [(visible)]="W002" modal="modal" width="800" [responsive]="true" (onHide)="selectedQuotaRowData=[]">
  <div class="p-8-0">
    <div class="m-r-15 inline-block">
      <span class="p-r-10">类型： </span>
      <p-dropdown placeholder="请选择类别" styleClass="width-200 m-r-30" [options]="quotaType" [(ngModel)]="selectQuotaType" [ngModelOptions]="{standalone: true}"
        optionLabel="name" (onChange)='searchQuota()' dataKey="code" required></p-dropdown>
    </div>

    <div class="width-250 relative pull-right">
      <input type="text" class="width-full p-input p-r-28" pInputText [(ngModel)]="searchQuotaObj.keyword" placeholder="名称/定额号"
        (keyUp.enter)="searchQuota()">
      <span class="icon-search-right" (click)="searchQuota()"></span>
    </div>
  </div>

  <p-dataTable scrollable="true" scrollHeight="260px" [style]="{marginTop:'12px'}" (onRowSelect)="selectedCk($event)" (onHeaderCheckboxToggle)="selectedAllCk($event)"
    [value]="quotaListForDialog" [totalRecords]="quotaTotalRecords" [loading]="loading" [lazy]="true" (onPage)="onPageQuota($event)"
    [paginator]="true" [(selection)]="selectedQuotaRowData" [headerCheckboxToggleAllPages]="true">
    <p-column [style]="{'width':'38px'}" selectionMode="multiple"></p-column>
    <p-column *ngFor="let col of quotaColForDialog" [field]='col.field' [header]='col.header' [hidden]="col.hidden" [style]="{'width':col.width}">
      <ng-template let-index="rowIndex" let-data="rowData" pTemplate="body" *ngIf="col.dic">
        <span> {{storage.dicFilter(col.dic,data[col.field])}} </span>
      </ng-template>

    </p-column>
  </p-dataTable>

  <div class="text-center">
    <button pButton type="button" [label]="'保存'" (click)="saveQuota()" class="btn btn-success m-btn-dialog"></button>
  </div>
</p-dialog>
